#include "glall.h"

#ifndef WIN32
#include <GL/glx.h>
#include <string.h>
#endif

#include "main.h"

int rt_ARB_multitexture = 0;
#if defined(GL_ARB_multitexture)
GLint num_texture_units = 1;
#if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB1_PROTOTYPES)
PFNGLACTIVETEXTUREARBPROC       glActiveTextureARB = 0;
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = 0;
PFNGLMULTITEXCOORD1DARBPROC     glMultiTexCoord1dARB = 0;
PFNGLMULTITEXCOORD1DVARBPROC    glMultiTexCoord1dvARB = 0;
PFNGLMULTITEXCOORD1FARBPROC     glMultiTexCoord1fARB = 0;
PFNGLMULTITEXCOORD1FVARBPROC    glMultiTexCoord1fvARB = 0;
PFNGLMULTITEXCOORD1IARBPROC     glMultiTexCoord1iARB = 0;
PFNGLMULTITEXCOORD1IVARBPROC    glMultiTexCoord1ivARB = 0;
PFNGLMULTITEXCOORD1SARBPROC     glMultiTexCoord1sARB = 0;
PFNGLMULTITEXCOORD1SVARBPROC    glMultiTexCoord1svARB = 0;
PFNGLMULTITEXCOORD2DARBPROC     glMultiTexCoord2dARB = 0;
PFNGLMULTITEXCOORD2DVARBPROC    glMultiTexCoord2dvARB = 0;
PFNGLMULTITEXCOORD2FARBPROC     glMultiTexCoord2fARB = 0;
PFNGLMULTITEXCOORD2FVARBPROC    glMultiTexCoord2fvARB = 0;
PFNGLMULTITEXCOORD2IARBPROC     glMultiTexCoord2iARB = 0;
PFNGLMULTITEXCOORD2IVARBPROC    glMultiTexCoord2ivARB = 0;
PFNGLMULTITEXCOORD2SARBPROC     glMultiTexCoord2sARB = 0;
PFNGLMULTITEXCOORD2SVARBPROC    glMultiTexCoord2svARB = 0;
PFNGLMULTITEXCOORD3DARBPROC     glMultiTexCoord3dARB = 0;
PFNGLMULTITEXCOORD3DVARBPROC    glMultiTexCoord3dvARB = 0;
PFNGLMULTITEXCOORD3FARBPROC     glMultiTexCoord3fARB = 0;
PFNGLMULTITEXCOORD3FVARBPROC    glMultiTexCoord3fvARB = 0;
PFNGLMULTITEXCOORD3IARBPROC     glMultiTexCoord3iARB = 0;
PFNGLMULTITEXCOORD3IVARBPROC    glMultiTexCoord3ivARB = 0;
PFNGLMULTITEXCOORD3SARBPROC     glMultiTexCoord3sARB = 0;
PFNGLMULTITEXCOORD3SVARBPROC    glMultiTexCoord3svARB = 0;
PFNGLMULTITEXCOORD4DARBPROC     glMultiTexCoord4dARB = 0;
PFNGLMULTITEXCOORD4DVARBPROC    glMultiTexCoord4dvARB = 0;
PFNGLMULTITEXCOORD4FARBPROC     glMultiTexCoord4fARB = 0;
PFNGLMULTITEXCOORD4FVARBPROC    glMultiTexCoord4fvARB = 0;
PFNGLMULTITEXCOORD4IARBPROC     glMultiTexCoord4iARB = 0;
PFNGLMULTITEXCOORD4IVARBPROC    glMultiTexCoord4ivARB = 0;
PFNGLMULTITEXCOORD4SARBPROC     glMultiTexCoord4sARB = 0;
PFNGLMULTITEXCOORD4SVARBPROC    glMultiTexCoord4svARB = 0;
#endif
#endif

int rt_ARB_texture_cube_map = 0;
#if defined(GL_ARB_texture_cube_map) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
#endif

int rt_ARB_texture_env_add = 0;
#if defined(GL_ARB_texture_env_add) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
#endif

int rt_ARB_texture_env_dot3 = 0;
#if defined(GL_ARB_texture_env_dot3) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
#endif

int rt_ARB_texture_env_combine = 0;
#if defined(GL_ARB_texture_env_combine) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
#endif

int rt_ARB_texture_env_crossbar = 0;
#if defined(GL_ARB_texture_env_crossbar) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
#endif

int rt_EXT_bgra = 0;
#if defined(GL_EXT_bgra) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_EXT1_PROTOTYPES)
#endif

int rt_NV_texture_env_combine4 = 0;
#if defined(GL_NV_texture_env_combine4) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_NV1_PROTOTYPES)
#endif

int rt_NV_register_combiners = 0;
#if defined(GL_NV_register_combiners)
GLint num_general_combiners = 1;
#if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_NV1_PROTOTYPES)
PFNGLCOMBINERPARAMETERFVNVPROC              glCombinerParameterfvNV = 0;
PFNGLCOMBINERPARAMETERFNVPROC               glCombinerParameterfNV = 0;
PFNGLCOMBINERPARAMETERIVNVPROC              glCombinerParameterivNV = 0;
PFNGLCOMBINERPARAMETERINVPROC               glCombinerParameteriNV = 0;
PFNGLCOMBINERINPUTNVPROC                    glCombinerInputNV = 0;
PFNGLCOMBINEROUTPUTNVPROC                   glCombinerOutputNV = 0;
PFNGLFINALCOMBINERINPUTNVPROC               glFinalCombinerInputNV = 0;
PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC      glGetCombinerInputParameterfvNV = 0;
PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC      glGetCombinerInputParameterivNV = 0;
PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC     glGetCombinerOutputParameterfvNV = 0;
PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC     glGetCombinerOutputParameterivNV = 0;
PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC glGetFinalCombinerInputParameterfvNV = 0;
PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC glGetFinalCombinerInputParameterivNV = 0;
#endif
#endif

int rt_ATI_fragment_shader = 0;
#if defined(GL_ATI_fragment_shader) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ATI1_PROTOTYPES)
PFNGLGENFRAGMENTSHADERSATIPROC          glGenFragmentShadersATI = 0;
PFNGLBINDFRAGMENTSHADERATIPROC          glBindFragmentShaderATI = 0;
PFNGLDELETEFRAGMENTSHADERATIPROC        glDeleteFragmentShaderATI = 0;
PFNGLBEGINFRAGMENTSHADERATIPROC         glBeginFragmentShaderATI = 0;
PFNGLENDFRAGMENTSHADERATIPROC           glEndFragmentShaderATI = 0;
PFNGLPASSTEXCOORDATIPROC                glPassTexCoordATI = 0;
PFNGLSAMPLEMAPATIPROC                   glSampleMapATI = 0;
PFNGLCOLORFRAGMENTOP1ATIPROC            glColorFragmentOp1ATI = 0;
PFNGLCOLORFRAGMENTOP2ATIPROC            glColorFragmentOp2ATI = 0;
PFNGLCOLORFRAGMENTOP3ATIPROC            glColorFragmentOp3ATI = 0;
PFNGLALPHAFRAGMENTOP1ATIPROC            glAlphaFragmentOp1ATI = 0;
PFNGLALPHAFRAGMENTOP2ATIPROC            glAlphaFragmentOp2ATI = 0;
PFNGLALPHAFRAGMENTOP3ATIPROC            glAlphaFragmentOp3ATI = 0;
PFNGLSETFRAGMENTSHADERCONSTANTATIPROC   glSetFragmentShaderConstantATI = 0;
#endif

int rt_ARB_vertex_buffer_object = 0;
#if defined(GL_ARB_vertex_buffer_object) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB3_PROTOTYPES)
PFNGLBINDBUFFERARBPROC              glBindBufferARB = 0;
PFNGLDELETEBUFFERSARBPROC           glDeleteBuffersARB = 0;
PFNGLGENBUFFERSARBPROC              glGenBuffersARB = 0;
PFNGLISBUFFERARBPROC                glIsBufferARB = 0;
PFNGLBUFFERDATAARBPROC              glBufferDataARB = 0;
PFNGLBUFFERSUBDATAARBPROC           glBufferSubDataARB = 0;
PFNGLGETBUFFERSUBDATAARBPROC        glGetBufferSubDataARB = 0;
PFNGLMAPBUFFERARBPROC               glMapBufferARB = 0;
PFNGLUNMAPBUFFERARBPROC             glUnmapBufferARB = 0;
PFNGLGETBUFFERPARAMETERIVARBPROC    glGetBufferParameterivARB = 0;
PFNGLGETBUFFERPOINTERVARBPROC       glGetBufferPointervARB = 0;
#endif

int rt_ARB_vertex_program = 0;
#if defined(GL_ARB_vertex_program) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB3_PROTOTYPES)
PFNGLVERTEXATTRIB1SARBPROC				glVertexAttrib1sARB = 0;
PFNGLVERTEXATTRIB1FARBPROC				glVertexAttrib1fARB = 0;
PFNGLVERTEXATTRIB1DARBPROC				glVertexAttrib1dARB = 0;
PFNGLVERTEXATTRIB2SARBPROC				glVertexAttrib2sARB = 0;
PFNGLVERTEXATTRIB2FARBPROC				glVertexAttrib2fARB = 0;
PFNGLVERTEXATTRIB2DARBPROC				glVertexAttrib2dARB = 0;
PFNGLVERTEXATTRIB3SARBPROC				glVertexAttrib3sARB = 0;
PFNGLVERTEXATTRIB3FARBPROC				glVertexAttrib3fARB = 0;
PFNGLVERTEXATTRIB3DARBPROC				glVertexAttrib3dARB = 0;
PFNGLVERTEXATTRIB4SARBPROC				glVertexAttrib4sARB = 0;
PFNGLVERTEXATTRIB4FARBPROC				glVertexAttrib4fARB = 0;
PFNGLVERTEXATTRIB4DARBPROC				glVertexAttrib4dARB = 0;
PFNGLVERTEXATTRIB4NUBARBPROC			glVertexAttrib4NubARB = 0;
PFNGLVERTEXATTRIB1SVARBPROC				glVertexAttrib1svARB = 0;
PFNGLVERTEXATTRIB1FVARBPROC				glVertexAttrib1fvARB = 0;
PFNGLVERTEXATTRIB1DVARBPROC				glVertexAttrib1dvARB = 0;
PFNGLVERTEXATTRIB2SVARBPROC				glVertexAttrib2svARB = 0;
PFNGLVERTEXATTRIB2FVARBPROC				glVertexAttrib2fvARB = 0;
PFNGLVERTEXATTRIB2DVARBPROC				glVertexAttrib2dvARB = 0;
PFNGLVERTEXATTRIB3SVARBPROC				glVertexAttrib3svARB = 0;
PFNGLVERTEXATTRIB3FVARBPROC				glVertexAttrib3fvARB = 0;
PFNGLVERTEXATTRIB3DVARBPROC				glVertexAttrib3dvARB = 0;
PFNGLVERTEXATTRIB4BVARBPROC				glVertexAttrib4bvARB = 0;
PFNGLVERTEXATTRIB4SVARBPROC				glVertexAttrib4svARB = 0;
PFNGLVERTEXATTRIB4IVARBPROC				glVertexAttrib4ivARB = 0;
PFNGLVERTEXATTRIB4UBVARBPROC			glVertexAttrib4ubvARB = 0;
PFNGLVERTEXATTRIB4USVARBPROC			glVertexAttrib4usvARB = 0;
PFNGLVERTEXATTRIB4UIVARBPROC			glVertexAttrib4uivARB = 0;
PFNGLVERTEXATTRIB4FVARBPROC				glVertexAttrib4fvARB = 0;
PFNGLVERTEXATTRIB4DVARBPROC				glVertexAttrib4dvARB = 0;
PFNGLVERTEXATTRIB4NBVARBPROC			glVertexAttrib4NbvARB = 0;
PFNGLVERTEXATTRIB4NSVARBPROC			glVertexAttrib4NsvARB = 0;
PFNGLVERTEXATTRIB4NIVARBPROC			glVertexAttrib4NivARB = 0;
PFNGLVERTEXATTRIB4NUBVARBPROC			glVertexAttrib4NubvARB = 0;
PFNGLVERTEXATTRIB4NUSVARBPROC			glVertexAttrib4NusvARB = 0;
PFNGLVERTEXATTRIB4NUIVARBPROC			glVertexAttrib4NuivARB = 0;
PFNGLVERTEXATTRIBPOINTERARBPROC			glVertexAttribPointerARB = 0;
PFNGLENABLEVERTEXATTRIBARRAYARBPROC		glEnableVertexAttribArrayARB = 0;
PFNGLDISABLEVERTEXATTRIBARRAYARBPROC	glDisableVertexAttribArrayARB = 0;
PFNGLPROGRAMSTRINGARBPROC				glProgramStringARB = 0;
PFNGLBINDPROGRAMARBPROC					glBindProgramARB = 0;
PFNGLDELETEPROGRAMSARBPROC				glDeleteProgramsARB = 0;
PFNGLGENPROGRAMSARBPROC					glGenProgramsARB = 0;
PFNGLPROGRAMENVPARAMETER4FARBPROC		glProgramEnvParameter4fARB = 0;
PFNGLPROGRAMENVPARAMETER4DARBPROC		glProgramEnvParameter4dARB = 0;
PFNGLPROGRAMENVPARAMETER4FVARBPROC		glProgramEnvParameter4fvARB = 0;
PFNGLPROGRAMENVPARAMETER4DVARBPROC		glProgramEnvParameter4dvARB = 0;
PFNGLPROGRAMLOCALPARAMETER4FARBPROC		glProgramLocalParameter4fARB = 0;
PFNGLPROGRAMLOCALPARAMETER4DARBPROC		glProgramLocalParameter4dARB = 0;
PFNGLPROGRAMLOCALPARAMETER4FVARBPROC	glProgramLocalParameter4fvARB = 0;
PFNGLPROGRAMLOCALPARAMETER4DVARBPROC	glProgramLocalParameter4dvARB = 0;
PFNGLGETPROGRAMENVPARAMETERFVARBPROC	glGetProgramEnvParameterfvARB = 0;
PFNGLGETPROGRAMENVPARAMETERDVARBPROC	glGetProgramEnvParameterdvARB = 0;
PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC	glGetProgramLocalParameterfvARB = 0;
PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC	glGetProgramLocalParameterdvARB = 0;
PFNGLGETPROGRAMIVARBPROC				glGetProgramivARB = 0;
PFNGLGETPROGRAMSTRINGARBPROC			glGetProgramStringARB = 0;
PFNGLGETVERTEXATTRIBDVARBPROC			glGetVertexAttribdvARB = 0;
PFNGLGETVERTEXATTRIBFVARBPROC			glGetVertexAttribfvARB = 0;
PFNGLGETVERTEXATTRIBIVARBPROC			glGetVertexAttribivARB = 0;
PFNGLGETVERTEXATTRIBPOINTERVARBPROC		glGetVertexAttribPointervARB = 0;
PFNGLISPROGRAMARBPROC					glIsProgramARB = 0;
#endif

int rt_ARB_fragment_program = 0;
#if defined(GL_ARB_fragment_program) && !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB3_PROTOTYPES)
#endif

#define FAILURE_MSG_GLEXT       "[FAILURE]"
#define SUCCESS_MSG_GLEXT       "[  O K  ]"
#define TEST_BEGIN(_message)    Log("  %-68s ", (_message))
#define TEST_END(_ok)           if (!(_ok)) { success = 0; Log("%s\n",FAILURE_MSG_GLEXT); } else Log("%s\n",SUCCESS_MSG_GLEXT)
#define DISPLAY_ADDR(_addr)     Log("    addr is 0x%08x\n", (_addr))
#ifdef WIN32
#define GET_FUNC_GLEXT(_name)   wglGetProcAddress(#_name)
#else
#define GET_FUNC_GLEXT(_name)   glXGetProcAddressARB((const GLubyte*)#_name)
#endif
#ifdef WIN32
#define LVALUE_GLEXT(_name)     (void*&)(_name)
#else
#define LVALUE_GLEXT(_name)     (void*)(_name)
#endif
#define CHECK_EXT(_name)  {\
        TEST_BEGIN(#_name);\
        LVALUE_GLEXT(_name) = GET_FUNC_GLEXT(_name);\
        TEST_END(_name != NULL);\
/*        DISPLAY_ADDR(_name);*/\
        }
#define START_CHECK(_string) Log("\nLooking for GL_%s...\n",#_string);\
        rt_##_string = strstr(extString, "GL_" #_string) != NULL;\
        if (int &success = rt_##_string) {
#define STOP_CHECK(_string) } Log("%-70s %s\n", "All extension GL_" #_string, rt_##_string ? SUCCESS_MSG_GLEXT : FAILURE_MSG_GLEXT)
#define BYPASS_CHECK(_string) rt_##_string = strstr(extString, "GL_" #_string) != NULL;\
        Log("\n%-70s %s\n", "Compile-time test for GL_" #_string, rt_##_string ? SUCCESS_MSG_GLEXT : FAILURE_MSG_GLEXT);
#define CANT_COMPILE(_string) if (strstr(extString, "GL_" #_string) != NULL)\
        Log("\n!! Not compiled for GL_%s :\n*  The extension is not used even though it seems to be available\n*  You could try compiling the program with a newer glext header\n",#_string)

void InitAllGL(void)
{
    const char *extString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));

/* We don't need all that initialization
#if defined(GL_ARB_multitexture)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB1_PROTOTYPES)
    START_CHECK(ARB_multitexture);
    {
        CHECK_EXT(glActiveTextureARB);
        CHECK_EXT(glClientActiveTextureARB);
        CHECK_EXT(glMultiTexCoord1dARB);
        CHECK_EXT(glMultiTexCoord1dvARB);
        CHECK_EXT(glMultiTexCoord1fARB);
        CHECK_EXT(glMultiTexCoord1fvARB);
        CHECK_EXT(glMultiTexCoord1iARB);
        CHECK_EXT(glMultiTexCoord1ivARB);
        CHECK_EXT(glMultiTexCoord1sARB);
        CHECK_EXT(glMultiTexCoord1svARB);
        CHECK_EXT(glMultiTexCoord2dARB);
        CHECK_EXT(glMultiTexCoord2dvARB);
        CHECK_EXT(glMultiTexCoord2fARB);
        CHECK_EXT(glMultiTexCoord2fvARB);
        CHECK_EXT(glMultiTexCoord2iARB);
        CHECK_EXT(glMultiTexCoord2ivARB);
        CHECK_EXT(glMultiTexCoord2sARB);
        CHECK_EXT(glMultiTexCoord2svARB);
        CHECK_EXT(glMultiTexCoord3dARB);
        CHECK_EXT(glMultiTexCoord3dvARB);
        CHECK_EXT(glMultiTexCoord3fARB);
        CHECK_EXT(glMultiTexCoord3fvARB);
        CHECK_EXT(glMultiTexCoord3iARB);
        CHECK_EXT(glMultiTexCoord3ivARB);
        CHECK_EXT(glMultiTexCoord3sARB);
        CHECK_EXT(glMultiTexCoord3svARB);
        CHECK_EXT(glMultiTexCoord4dARB);
        CHECK_EXT(glMultiTexCoord4dvARB);
        CHECK_EXT(glMultiTexCoord4fARB);
        CHECK_EXT(glMultiTexCoord4fvARB);
        CHECK_EXT(glMultiTexCoord4iARB);
        CHECK_EXT(glMultiTexCoord4ivARB);
        CHECK_EXT(glMultiTexCoord4sARB);
        CHECK_EXT(glMultiTexCoord4svARB);
    }
    STOP_CHECK(ARB_multitexture);
#   else
    BYPASS_CHECK(ARB_multitexture);
#   endif
    if (rt_ARB_multitexture) glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &num_texture_units);
#else
    CANT_COMPILE(GL_ARB_multitexture);
#endif

#if defined(GL_ARB_texture_cube_map)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
    START_CHECK(ARB_texture_cube_map);
    {
    }
    STOP_CHECK(ARB_texture_cube_map);
#   else
    BYPASS_CHECK(ARB_texture_cube_map);
#   endif
#else
    CANT_COMPILE(ARB_texture_cube_map);
#endif

#if defined(GL_ARB_texture_env_add)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
    START_CHECK(ARB_texture_env_add);
    {
    }
    STOP_CHECK(ARB_texture_env_add);
#   else
    BYPASS_CHECK(ARB_texture_env_add);
#   endif
#else
    CANT_COMPILE(ARB_texture_env_add);
#endif

#if defined(GL_ARB_texture_env_dot3)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
    START_CHECK(ARB_texture_env_dot3);
    {
    }
    STOP_CHECK(ARB_texture_env_dot3);
#   else
    BYPASS_CHECK(ARB_texture_env_dot3);
#   endif
#else
    CANT_COMPILE(ARB_texture_env_dot3);
#endif

#if defined(GL_ARB_texture_env_combine)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
    START_CHECK(ARB_texture_env_combine);
    {
    }
    STOP_CHECK(ARB_texture_env_combine);
#   else
    BYPASS_CHECK(ARB_texture_env_combine);
#   endif
#else
    CANT_COMPILE(ARB_texture_env_combine);
#endif

#if defined(GL_ARB_texture_env_crossbar)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB2_PROTOTYPES)
    START_CHECK(ARB_texture_env_crossbar);
    {
    }
    STOP_CHECK(ARB_texture_env_crossbar);
#   else
    BYPASS_CHECK(ARB_texture_env_crossbar);
#   endif
#else
    CANT_COMPILE(ARB_texture_env_crossbar);
#endif

#if defined(GL_EXT_bgra)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_EXT1_PROTOTYPES)
    START_CHECK(EXT_bgra);
    {
    }
    STOP_CHECK(EXT_bgra);
#   else
    BYPASS_CHECK(EXT_bgra);
#   endif
#else
    CANT_COMPILE(EXT_bgra);
#endif

#if defined(GL_NV_texture_env_combine4)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_NV1_PROTOTYPES)
    START_CHECK(NV_texture_env_combine4);
    {
    }
    STOP_CHECK(NV_texture_env_combine4);
#   else
    BYPASS_CHECK(NV_texture_env_combine4);
#   endif
#else
    CANT_COMPILE(NV_texture_env_combine4);
#endif

#if defined(GL_NV_register_combiners)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_NV1_PROTOTYPES)
    START_CHECK(NV_register_combiners);
    {
        CHECK_EXT(glCombinerParameterfvNV);
        CHECK_EXT(glCombinerParameterfNV);
        CHECK_EXT(glCombinerParameterivNV);
        CHECK_EXT(glCombinerParameteriNV);
        CHECK_EXT(glCombinerInputNV);
        CHECK_EXT(glCombinerOutputNV);
        CHECK_EXT(glFinalCombinerInputNV);
        CHECK_EXT(glGetCombinerInputParameterfvNV);
        CHECK_EXT(glGetCombinerInputParameterivNV);
        CHECK_EXT(glGetCombinerOutputParameterfvNV);
        CHECK_EXT(glGetCombinerOutputParameterivNV);
        CHECK_EXT(glGetFinalCombinerInputParameterfvNV);
        CHECK_EXT(glGetFinalCombinerInputParameterivNV);
    }
    STOP_CHECK(NV_register_combiners);
#   else
    BYPASS_CHECK(NV_register_combiners);
#   endif
    if (rt_NV_register_combiners) glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &num_general_combiners);
#else
    CANT_COMPILE(NV_register_combiners);
#endif

#if defined(GL_ATI_fragment_shader)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ATI1_PROTOTYPES)
    START_CHECK(ATI_fragment_shader);
    {
        CHECK_EXT(glGenFragmentShadersATI);
        CHECK_EXT(glBindFragmentShaderATI);
        CHECK_EXT(glDeleteFragmentShaderATI);
        CHECK_EXT(glBeginFragmentShaderATI);
        CHECK_EXT(glEndFragmentShaderATI);
        CHECK_EXT(glPassTexCoordATI);
        CHECK_EXT(glSampleMapATI);
        CHECK_EXT(glColorFragmentOp1ATI);
        CHECK_EXT(glColorFragmentOp2ATI);
        CHECK_EXT(glColorFragmentOp3ATI);
        CHECK_EXT(glAlphaFragmentOp1ATI);
        CHECK_EXT(glAlphaFragmentOp2ATI);
        CHECK_EXT(glAlphaFragmentOp3ATI);
        CHECK_EXT(glSetFragmentShaderConstantATI);
    }
    STOP_CHECK(ATI_fragment_shader);
#   else
    BYPASS_CHECK(ATI_fragment_shader);
#   endif
#else
    CANT_COMPILE(ATI_fragment_shader);
#endif
*/
#if defined(GL_ARB_vertex_buffer_object)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB3_PROTOTYPES)
    START_CHECK(ARB_vertex_buffer_object);
    {
        CHECK_EXT(glBindBufferARB);
        CHECK_EXT(glDeleteBuffersARB);
        CHECK_EXT(glGenBuffersARB);
        CHECK_EXT(glIsBufferARB);
        CHECK_EXT(glBufferDataARB);
        CHECK_EXT(glBufferSubDataARB);
        CHECK_EXT(glGetBufferSubDataARB);
        CHECK_EXT(glMapBufferARB);
        CHECK_EXT(glUnmapBufferARB);
        CHECK_EXT(glGetBufferParameterivARB);
        CHECK_EXT(glGetBufferPointervARB);
    }
    STOP_CHECK(ARB_vertex_buffer_object);
#   else
    BYPASS_CHECK(ARB_vertex_buffer_object);
#   endif
#else
    CANT_COMPILE(ARB_vertex_buffer_object);
#endif

#if defined(GL_ARB_vertex_program)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB3_PROTOTYPES)
    START_CHECK(ARB_vertex_program);
    {
        CHECK_EXT(glVertexAttrib1sARB);
        CHECK_EXT(glVertexAttrib1fARB);
        CHECK_EXT(glVertexAttrib1dARB);
        CHECK_EXT(glVertexAttrib2sARB);
        CHECK_EXT(glVertexAttrib2fARB);
        CHECK_EXT(glVertexAttrib2dARB);
        CHECK_EXT(glVertexAttrib3sARB);
        CHECK_EXT(glVertexAttrib3fARB);
        CHECK_EXT(glVertexAttrib3dARB);
        CHECK_EXT(glVertexAttrib4sARB);
        CHECK_EXT(glVertexAttrib4fARB);
        CHECK_EXT(glVertexAttrib4dARB);
        CHECK_EXT(glVertexAttrib4NubARB);
        CHECK_EXT(glVertexAttrib1svARB);
        CHECK_EXT(glVertexAttrib1fvARB);
        CHECK_EXT(glVertexAttrib1dvARB);
        CHECK_EXT(glVertexAttrib2svARB);
        CHECK_EXT(glVertexAttrib2fvARB);
        CHECK_EXT(glVertexAttrib2dvARB);
        CHECK_EXT(glVertexAttrib3svARB);
        CHECK_EXT(glVertexAttrib3fvARB);
        CHECK_EXT(glVertexAttrib3dvARB);
        CHECK_EXT(glVertexAttrib4bvARB);
        CHECK_EXT(glVertexAttrib4svARB);
        CHECK_EXT(glVertexAttrib4ivARB);
        CHECK_EXT(glVertexAttrib4ubvARB);
        CHECK_EXT(glVertexAttrib4usvARB);
        CHECK_EXT(glVertexAttrib4uivARB);
        CHECK_EXT(glVertexAttrib4fvARB);
        CHECK_EXT(glVertexAttrib4dvARB);
        CHECK_EXT(glVertexAttrib4NbvARB);
        CHECK_EXT(glVertexAttrib4NsvARB);
        CHECK_EXT(glVertexAttrib4NivARB);
        CHECK_EXT(glVertexAttrib4NubvARB);
        CHECK_EXT(glVertexAttrib4NusvARB);
        CHECK_EXT(glVertexAttrib4NuivARB);
        CHECK_EXT(glVertexAttribPointerARB);
        CHECK_EXT(glEnableVertexAttribArrayARB);
        CHECK_EXT(glDisableVertexAttribArrayARB);
        CHECK_EXT(glProgramStringARB);
        CHECK_EXT(glBindProgramARB);
        CHECK_EXT(glDeleteProgramsARB);
        CHECK_EXT(glGenProgramsARB);
        CHECK_EXT(glProgramEnvParameter4fARB);
        CHECK_EXT(glProgramEnvParameter4dARB);
        CHECK_EXT(glProgramEnvParameter4fvARB);
        CHECK_EXT(glProgramEnvParameter4dvARB);
        CHECK_EXT(glProgramLocalParameter4fARB);
        CHECK_EXT(glProgramLocalParameter4dARB);
        CHECK_EXT(glProgramLocalParameter4fvARB);
        CHECK_EXT(glProgramLocalParameter4dvARB);
        CHECK_EXT(glGetProgramEnvParameterfvARB);
        CHECK_EXT(glGetProgramEnvParameterdvARB);
        CHECK_EXT(glGetProgramLocalParameterfvARB);
        CHECK_EXT(glGetProgramLocalParameterdvARB);
        CHECK_EXT(glGetProgramivARB);
        CHECK_EXT(glGetProgramStringARB);
        CHECK_EXT(glGetVertexAttribdvARB);
        CHECK_EXT(glGetVertexAttribfvARB);
        CHECK_EXT(glGetVertexAttribivARB);
        CHECK_EXT(glGetVertexAttribPointervARB);
        CHECK_EXT(glIsProgramARB);
    }
    STOP_CHECK(ARB_vertex_program);
#   else
    BYPASS_CHECK(ARB_vertex_program);
#   endif
#else
    CANT_COMPILE(ARB_vertex_program);
#endif

#if defined(GL_ARB_fragment_program)
#   if !defined(GL_GLEXT_PROTOTYPES) && !defined(FORCE_ARB3_PROTOTYPES)
    START_CHECK(ARB_fragment_program);
    {
    }
    STOP_CHECK(ARB_fragment_program);
#   else
    BYPASS_CHECK(ARB_fragment_program);
#   endif
#else
    CANT_COMPILE(ARB_fragment_program);
#endif
}
